package com.yunyao.common.constant.enums;

import lombok.Getter;

/**
 * 供货状态
 * @author chenyejian
 * @date 2024-07-21
 */
@Getter
public enum SupplyListStatus {
    /**
     * res.supplystatus =“供货清单未提交”。} else
     * if (res.supplystatus ="1")
     * res.supplystatus =“待上传送货单”;else
     * if(res.supplystatus =="2"){res.supplystatus =“撤回”} else
     * if (res.supplystatus == “3"){res.supplystatus =“云采确认驳回”;else
     * if(res.supplystatus =-"4"){res.supplystatus=“待项目验收”;+else
     * if (res.supplystatus"5”)res.supplystatus =“项目验收完成”+ else
     * if (res.supplystatus -- "6”){res.supplystatus =“待云采确认”;
     */
    UN_SUBMIT(0, "供货清单未提交"),
    UN_UPLOAD_ORDER(1, "待上传送货单"),
    REVOKE(2, "撤回"),
    YUNCAI_CONFIRMATION_REJECTED(3, "云采确认驳回"),
    WAIT_PROJECT_ACCEPTANCE(4, "待项目验收"),
    PROJECT_ACCEPTANCE_COMPLETED(5, "项目验收完成"),
    WAIT_YUNCAI_CONFIRMATION(6, "待云采确认");

    private final Integer type;
    private final String description;

    SupplyListStatus(int type, String description) {
        this.type = type;
        this.description = description;
    }

    /**
     * 可以根据 type 获取枚举实例
     */
    public static String getDescriptionByType(Integer type) {
        for (SupplyListStatus status : SupplyListStatus.values()) {
            if (type == (status.getType())) {
                return status.getDescription();
            }
        }
        return null;
    }

    /**
     * 可以根据 description 获取枚举实例
     */
    public static Integer getTypeByDesc(String description) {
        for (SupplyListStatus status : SupplyListStatus.values()) {
            if (description.equalsIgnoreCase(status.getDescription())) {
                return status.getType();
            }
        }
        return null;
    }
}
